//
//  BaseHttpRequest.h
//  didacar
//
//  Created by 度周末网络-王腾 on 15/11/20.
//  Copyright © 2015年 dzmmac. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YRJSONAdapter.h"
#import "AFNetworking.h"
#import "ApiConfig.h"
#import "Jastor.h"
#import "NSString+Additions.h"

#define App_Account				@"e803391f-ff2e-4dcb-8c6a-491439323c8b"
#define App_Version             [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

typedef void (^RequestFailBlock)(NSString *errorMsg);

@interface BaseHttpRequest : NSObject

+ (BaseHttpRequest *)sharedInstance;

/**
 *  @brief  下载文件
 *
 *  @param paramDic   附加post参数
 *  @param requestURL 请求地址
 *  @param savedPath  保存 在磁盘的位置
 *  @param success    下载成功回调
 *  @param failure    下载失败回调
 *  @param progress   实时下载进度回调
 */
- (void)downloadFileWithOption:(NSDictionary *)paramDic
                 withInferface:(NSString*)requestURL
                     savedPath:(NSString*)savedPath
               downloadSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
               downloadFailure:(void (^)(AFHTTPRequestOperation *operation, NSError *errorMsg))failure
                      progress:(void (^)(float progress))progress;

/**
 *  @brief Get方式请求数据
 *
 *  @param strUrl       URL
 *  @param successBlock 成功回掉
 *  @param errorBlock   失败回掉
 */
-(void)dataGetHttpRequestWithUrl:(NSString*)strUrl
                         success:(void (^)(NSString *stringData))successBlock
                           error:(void (^)(NSString *errorMsg)) errorBlock;


/**
 *  @brief POST方式请求数据
 *
 *  @param actionName    POST 接口名称
 *  @param requestEntity 请求的参数:接受继承于jastor的对象以及字典对象
 *  @param alertMessage  是否有提示框出现  nil  不出现
 *  @param successBlock  成功回掉
 *  @param errorBlock    失败回掉
 */
- (void)sendRequestToPost:(NSString*)actionName
                 withData:(id) requestEntity
             alertMessage:(NSString *)alertMessage
                  success:(void (^)(NSDictionary *dicData)) successBlock
                    error:(void (^)(NSString *errorMsg)) errorBlock;


-(void)requestCanelOne;

-(void)requestCanelAll;



@end
